<template>
	<view class="page">
		
		<!-- 填写区 -->
		<view class="input-info">
			<view class="info">
				<input type="text" v-model="form.uuid"  placeholder="请输入用户ID" @blur="getData">
				<view class="more">
			
				</view>
			</view>
			<view class="info">
				<input type="text" v-model="form.name" placeholder="用户昵称" :disabled="true">
				<view class="more">
			
				</view>
			</view>
			
			<view class="info">
				<input type="number" v-model="form.num"  placeholder="请输入赠送数量">
				<view class="more">

				</view>
			</view>
		</view>
		<!-- 按钮 -->
		<view class="btn-info">
			<view class="btn" :style="isRegister?'opacity:1':'opacity:0.4'" @click="tui.dianji(sumid)">
				<text>提交</text>
			</view>
		</view>
		<!-- 操作 -->
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				// 表单
				form: {
					name: '',
					num:'',
					uuid:'',
					
				},
				djs:'获取验证码',
				is_btn:false,
				timer:null,
				isRegister:false
			};
		},
		onLoad(option) {
			console.log(option)
			this.form.inviter_code =option.recommend
		},
		onNavigationBarButtonTap() {
			this.tui.href('/pages/tuanzhang/zz_jilu')
		},
		methods: {
			onLogin() {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			},
			/**
			 * 注册点击
			 */
			getData(){
				let that = this
				that.tui.request("api.auth.egg/searchUserInfo", "POST",{uuid:that.form.uuid} , false, true, true).then((res) => {
					if(res.code==1){
						that.form.name = res.data.nickname
					}
					
				}).catch((res) => {})
			},
			get_code(){
				let that = this
				if(that.form.phone==''){
					that.tui.toast('请输入手机号');
					return;
				}
				if(that.is_btn){return false}
				let url = ''
				that.tui.request("api.login/send", "POST",{phone:that.form.phone} , false, true, true).then((res) => {
					that.djs = 60
					that.is_btn = true
					that.tui.toast('发送成功');
					that.timer=setInterval(function(){
						that.djs--
						if(that.djs==0){
							clearInterval(that.timer)
							that.djs = '获取验证码'
							that.is_btn = false
						}
					},1000)
				}).catch((res) => {})
			},
			sumid() {
				let that = this
				that.tui.request("api.auth.egg/transfer", "POST", that.form, false, false, false).then((res) => {
					that.tui.toast(res.info)
					if(res.code==1){
						that.form.uuid=''
						that.form.num = ''
						that.form.name=''
					}
					
				}).catch((res) => {
					
				})
				
			},
		},
		watch: {
			form: {
				handler(newValue, oldValue) {
					if (newValue.name && newValue.uuid &&newValue.num) {
						this.isRegister = true;
					} else {
						this.isRegister = false;
					}
				},
				deep: true
			}
		},
		
	}
</script>

<style scoped lang="scss">
	.page{
	  position: absolute;
	  left: 0;
	  top: 0;
	  width: 100%;
	  height: 100%;
	  background-color: #FFFFFF;
	}
	
	/* 填写 */
	.input-info{
	  padding: 0 6%;
	  .info{
	    display: flex;
	    align-items:center;
	    justify-content: space-between;
	    width: 100%;
	    height: 100rpx;
	    border-bottom: 2rpx solid #f6f6f6;
	    input{
	      width: 70%;
	      height: 100%;
	      font-size: 26rpx;
	      color: #222222;
	    }
	    .more{
	      display: flex;
	      align-items: center;
	      justify-content: flex-end;
	      width: 30%;
	      height: 100%;
	      .iconfont{
	        font-size: 34rpx;
	      }
	      .mo{
	        font-size: 26rpx;
	        padding-left: 20rpx;
	        margin-left: 10rpx;
	        border-left: 2rpx solid #EEEEEE;
	      }
	    }
	  }
	}
	/* 按钮 */
	.btn-info{
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  width: 100%;
	  height: 100rpx;
	  margin-top: 40rpx;
	  .btn{
	    display: flex;
	    align-items: center;
	    justify-content: center;
	    width: 90%;
	    height: 80rpx;
	    background: linear-gradient(to right,$base,$change-clor);
	    border-radius: 100rpx;
	    color: #FFFFFF;
	    font-size: 28rpx;
	    opacity: 0.4;
	  }
	}
	/* 操作 */
	.operation{
	  display: flex;
	  align-items: center;
	  justify-content: space-between;
	  padding: 0 6%;
	  height: 80rpx;
	  text{
	    font-size: 28rpx;
	    color: #555555;
	  }
	}
	
	/* 其他 */
	.other-ways{
	  display: flex;
	  align-items: center;
	  justify-content: space-between;
	  width: 100%;
	  height: 80rpx;
	  margin-top: 100rpx;
	  text{
	    font-size: 28rpx;
	    color: #999999;
	  }
	}
	.other-ways::after{
	  content: "";
	  width: 36%;
	  height: 2rpx;
	  background-color: #EEEEEE;
	}
	.other-ways::before{
	  content: "";
	  width: 36%;
	  height: 2rpx;
	  background-color: #EEEEEE;
	}
	/* 登录方式 */
	.login-way{
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  width: 100%;
	  height: 200rpx;
	  .way{
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	    width: 50%;
	    height: 100%;
	    image{
	      width: 100rpx;
	      height: 100rpx;
	    }
	    text{
	      font-size: 28rpx;
	      color: #959595;
	      margin-top: 20rpx;
	    }
	  }
	}
	
</style>